<template>
	<view class="content">
		<view class="table" v-loading="loading">
			<el-table :data="tableData" border style="width: 100%">
				<el-table-column prop="nickName" label="名称">
				</el-table-column>
				<el-table-column label="头像">
					<template slot-scope="scope">
						<el-image style="width: 100px; height: 100px" :src="scope.row.avatarUrl">
						</el-image>
					</template>
				</el-table-column>
				<el-table-column prop="country" label="国家">
				</el-table-column>
				<el-table-column prop="province" label="地区">
				</el-table-column>
				<el-table-column label="操作">
					<el-button type="danger" size="medium">删除</el-button>
				</el-table-column>
			</el-table>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tableData: [],
				pageIndex: 1,
				pageSize: 5
			};
		},
		created() {
			this.get()
		},
		methods: {
			// 获取列表
			async get() {
				this.loading = true
				return await uniCloud.callFunction({
					name: 'get',
					data: {
						tableName: 'we-userInfo', //要查询的表名
						// filter: {
						// 	name: this.seranch.name,
						// },
						pageIndex: this.pageIndex, //第几页
						pageSize: this.pageSize //每页的记录条数
					}
				}).then((res) => {
					uni.hideLoading()
					this.tableData = res.result.data
					this.total = res.result.total
					this.loading = false
					return res.result.data
				}).catch((err) => {
					uni.hideLoading()
					uni.showModal({
						content: `查询失败，错误信息为：${err.message}`,
						showCancel: false
					})
					console.error(err)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 40upx;
	}
</style>
